#include "configargs.h"
#include<QString>
#include <QMessageBox>
#include<stdio.h>

QString g_lcdsize;
QString g_cmdline;


int  WIDGET_H_Info = 0 ;
int  WIDGET_W_Info  =0 ;

int int_WIDGET_H  =0  ;
int TOPMARGIN   =0  ;
int BOTTOMMARGIN  =0 ;
int LEFTMARGIN  =0  ;
int RIGHTMARGIN =0 ;
int int_WIDGET_W  =0  ;

int SUBLEFTMARGIN =0  ;
int SUBTOPMARGIN   =0 ;
int SUBRIGHTMARGIN  =0  ;
int SUBBOTTOMMARGIN  =0 ;
int SUBSPACE    =0   ;

int SIDEBAR_H  =0 ;
int SIDEBAR_W  =0 ;

int SUBWIDGET_H  =0 ;
int SUBWIDGET_W =0  ;
int SUBWIDGET_X  =0 ;
int SUBWIDGET_Y  =0 ;


int USERWIDGET_MARGIN =0   ;



int USERWIDGET_BLUEFRAME_W  =0;
int USERWIDGET_BLUEFRAME_H =0 ;
int USERWIDGET_WHITEFRAME_W  =0;
int USERWIDGET_WHITEFRAME_H  =0 ;
int flags_dianzu  =0 ;

 unsigned  int  long long  sentcont=0;
 unsigned  int  long long  receivecont=0  ;

 unsigned   int long long  cansentcont=0;
 unsigned  int long long canreceivecont=0  ;

 QString retmp;
/*
int IsIPaddress(QString ip) {
 QRegExp rx2("^([1]?/d/d?|2[0-4]/d|25[0-5])/.([1]?/d/d?|2[0-4]/d|25[0-5])/.([1]?/d/d?|2[0-4]/d|25[0-5])/.([1]?/d/d?|2[0-4]/d|25[0-5])$");
 if( !rx2.exactMatch(ip) )
 {
       qDebug("error by crl6");
       return 0;
 }
 return 1;
}*/
 int IsNub(QString ip) {
      QRegExp rx("[0-9]+");
      if( !rx.exactMatch( ip) ) {
          return 0;
      }
      return 1;
 }

 int IsIPaddress(QString ip) {
     int i=0;
     int a[4];
     char *str;

      QByteArray ba = ip.toLatin1();
      str = ba.data();
     if( sscanf(str,"%d.%d.%d.%d",&a[0],&a[1],&a[2],&a[3]) !=4 )
         return 0;
     for(i=0;i<4;i++) {
         if(a[i] <0 ||a[i] >255)
             return 0;
         return 1;
     }
 }

 int IsMACaddress(QString ip) {
     int i=0;
     int a[6];
     char *str;

      QByteArray ba = ip.toLatin1();
      str = ba.data();
     // qDebug("start");
     if( sscanf(str,"%x:%x:%x:%x:%x:%x",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5]) !=6 ) {
            //  qDebug("end");
         return 0;
     }
     qDebug("a[0]=%d",a[0]);
     if((a[0]%2)!=0 ) {// di yi wei bu wei ou shu
      //  qDebug("fei ou shu");
         return 0;
     }
     for(i=0;i<6;i++) {
         if(a[i] <0 ||a[i] > 255)
             return 0;
         return 1;
     }
 }

 /*

 int IsIPaddress(QString ip)
 {
     QRegExp rx2("(//d+)(//.)(//d+)(//.)(//d+)(//.)(//d +)");

     int pos = rx2.indexIn(ip);
     qDebug("pos=%d",pos);

     if(pos>-1)
     {
          for(int i=0;i<4;i++)
         {
             if( rx2.cap(i*2+1).toInt()>=255 )
             {
                qDebug("erro by me 1 ");
                 return 0;
             }
         }

         if(rx2.cap(7).toInt()==0)
         {
                qDebug("erro by me 2");
                return 0;
         }

         if(rx2.cap(7).toInt()==0)
         {
                qDebug("erro by me 3");
                return 0;
         }
     }
     else
     {
         qDebug("erro by me 4 ");
         return 0;
     }

     return 1;
 }
*/
